package com.gmics.unifiq.adapter;
 
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.gmics.android.R;
 
public class FAQAdapter extends BaseExpandableListAdapter {
 
    private Activity context;
    private List<String> faqParent, faqChild;
 
    public FAQAdapter(Activity context, List<String> faqParent,
            List<String> faqChild) {
        this.context = context;
        this.faqParent = faqParent;
        this.faqChild = faqChild;
    }
 
    @Override
	public Object getChild(int groupPosition, int childPosition) {
        return faqChild.get(groupPosition);
    }
 
    @Override
	public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }
 
    @Override
	public int getChildrenCount(int groupPosition) {
        return 1;
    }
 
    @Override
	public View getChildView(final int groupPosition, final int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        String msg = (String) getChild(groupPosition, childPosition);
        LayoutInflater inflater = context.getLayoutInflater();
 
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.faq_child_list_item, null);
        }
 
        TextView item = (TextView) convertView.findViewById(R.id.faq_child_tv);
        item.setText(msg);
        
        return convertView;
    }
 
    @Override
	public Object getGroup(int groupPosition) {
        return faqParent.get(groupPosition);
    }
 
    @Override
	public int getGroupCount() {
        return faqParent.size();
    }
 
    @Override
	public long getGroupId(int groupPosition) {
        return groupPosition;
    }
 
    @Override
	public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        String faqParent = (String) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(android.R.layout.simple_expandable_list_item_1 ,
                    null);
        }
        TextView item = (TextView) convertView.findViewById(android.R.id.text1);
        item.setText(faqParent);
        return convertView;
    }
 
    @Override
	public boolean hasStableIds() {
        return true;
    }
 
    @Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
}
